{% macro compare(target, base) %}
  {% if target > base %}
    <div class="better"><span class="measure">{{ (target / base) | round(method="ceil",precision=2) }}x</span><br>faster</div>
  {% else %}
    <div class="worse"><span class="measure">{{ (base / target) | round(method="ceil",precision=2) }}x</span><br>slower</div>
  {% endif %}
{% endmacro compare %}

{% macro speedo(id, rustls, openssl, boringssl, unit) %}
  {% set max = [rustls, openssl, boringssl] | sort | last %}
  {% set max = (max / 100) | round %}
  {% set max = max * 100 + 100 %}
  {% set zero_offset = 16 %}
  {% set full_scale = 210 %}
  {% set rustls_angle = rustls / max * full_scale - 180 - zero_offset %}
  {% set openssl_angle = openssl / max * full_scale - zero_offset %}
  {% set boringssl_angle = boringssl / max * full_scale - zero_offset %}
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   width="143.59505mm"
   height="92.405914mm"
   viewBox="0 0 143.59505 92.405914"
   version="1.1"
   id="{{id}}"
   class="speedo"
   inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
   sodipodi:docname="speedy.svg"
   xml:space="preserve"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
   id="namedview7"
   pagecolor="#ffffff"
   bordercolor="#000000"
   borderopacity="0.25"
   inkscape:showpageshadow="2"
   inkscape:pageopacity="0"
   inkscape:pagecheckerboard="true"
   inkscape:deskcolor="#d1d1d1"
   inkscape:document-units="mm"
   showgrid="false"
   inkscape:zoom="1.1106968"
   inkscape:cx="268.75021"
   inkscape:cy="243.54081"
   inkscape:window-width="1920"
   inkscape:window-height="1017"
   inkscape:window-x="0"
   inkscape:window-y="0"
   inkscape:window-maximized="1"
   inkscape:current-layer="layer3" /><defs
   id="defs2"><linearGradient
     inkscape:collect="always"
     id="linearGradient2466"><stop
       style="stop-color:#929292;stop-opacity:0;"
       offset="0"
       id="stop2462" /><stop
       style="stop-color:#ffffff;stop-opacity:1;"
       offset="0.53078657"
       id="stop2470" /><stop
       style="stop-color:#929292;stop-opacity:0;"
       offset="1"
       id="stop2464" /></linearGradient><linearGradient
     inkscape:collect="always"
     id="linearGradient890"><stop
       style="stop-color:#3a517f;stop-opacity:1;"
       offset="0.56708783"
       id="stop886" /><stop
       style="stop-color:#ffffff;stop-opacity:0.47614279;"
       offset="1"
       id="stop888" /></linearGradient><filter
     style="color-interpolation-filters:sRGB"
     inkscape:label="Drop Shadow"
     id="filter6298"
     x="-0.24"
     y="-0.24"
     width="1.48"
     height="1.48"><feFlood
       flood-opacity="0.278431"
       flood-color="rgb(224,224,224)"
       result="flood"
       id="feFlood6288" /><feComposite
       in="flood"
       in2="SourceGraphic"
       operator="in"
       result="composite1"
       id="feComposite6290" /><feGaussianBlur
       in="composite1"
       stdDeviation="1"
       result="blur"
       id="feGaussianBlur6292" /><feOffset
       dx="0"
       dy="0"
       result="offset"
       id="feOffset6294" /><feComposite
       in="SourceGraphic"
       in2="offset"
       operator="over"
       result="composite2"
       id="feComposite6296" /></filter><radialGradient
     inkscape:collect="always"
     xlink:href="#linearGradient890"
     id="radialGradient892"
     cx="-72.098885"
     cy="-87.799446"
     fx="-72.098885"
     fy="-87.799446"
     r="71.793394"
     gradientTransform="matrix(-0.95696731,-0.29019575,0.28404588,-0.93668714,-120.79254,-225.4762)"
     gradientUnits="userSpaceOnUse" /><linearGradient
     inkscape:collect="always"
     xlink:href="#linearGradient2466"
     id="linearGradient2468"
     x1="84.338524"
     y1="94.104164"
     x2="84.338524"
     y2="96.74173"
     gradientUnits="userSpaceOnUse" /></defs><g
   inkscape:label="bottom"
   inkscape:groupmode="layer"
   id="layer1"
   transform="translate(-36.661166,-23.496595)"><path
     style="fill:none;stroke:url(#radialGradient892);stroke-width:20;stroke-dasharray:2, 2;stroke-dashoffset:0;stroke-opacity:1"
     id="back"
     sodipodi:type="arc"
     sodipodi:cx="-76.785446"
     sodipodi:cy="-122.25368"
     sodipodi:rx="61.793808"
     sodipodi:ry="61.793808"
     sodipodi:start="0"
     sodipodi:end="3.7509585"
     sodipodi:arc-type="arc"
     d="m -14.991638,-122.25368 a 61.793808,61.793808 0 0 1 -42.327576,58.647598 61.793808,61.793808 0 0 1 -68.995566,-21.697364 61.793808,61.793808 0 0 1 -1.14228,-72.317764"
     sodipodi:open="true"
     transform="rotate(163.43175)" /></g><g
   inkscape:groupmode="layer"
   id="layer4"
   inkscape:label="val2"><path
     style="display:inline;fill:#d3d3d3;fill-opacity:0.556997;stroke:none;stroke-width:13.9734;stroke-dasharray:1.39734, 1.39734"
     d="m 71.886003,73.289314 -51.11287,-0.98941 -0.0127,-0.8325 51.05399,-1.01846 4.17721,0.46849 0.012,1.92454 z"
     id="path2644"
     transform="rotate({{openssl_angle}},71,73)"
     sodipodi:nodetypes="ccccccc"
     inkscape:label="value2"
     inkscape:transform-center-x="23.423722"
     inkscape:transform-center-y="0.0049348419"><title>OpenSSL {{openssl}} {{unit}}</title></path></g><g
   inkscape:groupmode="layer"
   id="layer3"
   inkscape:label="val1"><path
     style="display:inline;fill:#d3d3d3;fill-opacity:0.556997;stroke:none;stroke-width:13.9734;stroke-dasharray:1.39734, 1.39734"
     d="m 71.886003,73.289314 -51.11287,-0.98941 -0.0127,-0.8325 51.05399,-1.01846 4.17721,0.46849 0.012,1.92454 z"
     id="path2406"
     sodipodi:nodetypes="ccccccc"
     transform="rotate({{boringssl_angle}},71,73)"
     inkscape:label="value1"
     inkscape:transform-center-x="23.483269"
     inkscape:transform-center-y="0.090472108"><title>BoringSSL {{boringssl}} {{unit}}</title></path></g><g
   inkscape:groupmode="layer"
   id="layer2"
   inkscape:label="top"
   transform="translate(-36.661166,-23.496595)"
   style="display:inline"><g
     id="needle"
     transform="rotate({{rustls_angle}},108.52247,95.364171)"
     style="display:inline"><circle
       style="fill:#f3f3f3;fill-opacity:1;stroke:none;stroke-width:20;stroke-dasharray:2, 2;filter:url(#filter6298)"
       id="path5796"
       cx="108.45869"
       cy="95.099586"
       r="5" /><path
       style="fill:url(#linearGradient2468);fill-opacity:1;stroke:none;stroke-width:13.9734;stroke-dasharray:1.39734, 1.39734"
       d="m 108.54717,96.785909 -51.11287,-0.98941 -0.0127,-0.8325 51.05399,-1.01846 4.17721,0.46849 0.012,1.92454 z"
       id="needle-hilight"
       sodipodi:nodetypes="ccccccc"
       transform="rotate(180,108.52247,95.36417)"
       inkscape:label="needle-hilight" /><path
       style="fill:#f7f7f7;fill-opacity:0.849118;stroke:none;stroke-width:20;stroke-dasharray:2, 2"
       d="m 108.49777,92.474034 51.11287,2.026892 0.0127,1.705444 -51.05399,2.086409 -4.17721,-0.959742 -0.012,-3.942589 z"
       id="path7443"
       sodipodi:nodetypes="ccccccc" /><circle
       style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:20;stroke-dasharray:2, 2"
       id="path5796-3"
       cx="108.50889"
       cy="95.118073"
       r="4" /><title>rustls {{rustls}} {{unit}}</title></g></g>
</svg>


{% endmacro speedo %}
